/*
 * 客户端埋点工具函数
 */
import { useEffect } from 'react'
import mnb from '@mf2e/mnb'

// 银河统计
export const track = (event, info) => {
  mnb('track.sendEvent', {
    eventId: event,
    kv: Object.assign({}, info),
  })
}

// 点击统计
export const onPressTrack = (fn, event, info) => {
  return () => {
    track(event, info)
    return fn()
  }
}

// 查看统计
export const useViewTrack = (event, info) => {
  useEffect(() => {
    track(event, info)
  }, [event, info])
}
